package org.btik.light.mobile.ui.devs.mecanum.wheel.car;


import android.view.View;
import android.widget.CompoundButton;
import org.btik.light.mobile.common.handler.SimpleController;
import org.btik.light.mobile.common.handler.SimpleSpeedController;
import org.btik.light.mobile.common.handler.adaptor.SpeedHandler;
import org.btik.light.mobile.common.handler.adaptor.TurnEventHandler;

/**
 * @author lustre
 * @since 2022/12/20 15:27
 */
public interface MecanumWheelCarHandlers {
    int CAR_GENERAL_OP = 1;
    String FORWARD = "0";
    String BACKWARD = "1";
    String TURN_LEFT = "2";
    String TURN_RIGHT = "3";
    String END_TURN_LEFT = "4";
    String END_TURN_RIGHT = "5";
    String STOP = "6";
    String GO_PIKACHU = "7";

    String GO_FRONT_LEFT = "8";
    String GO_REAR_LEFT = "8";
    String GO_RIGHT_FRONT = "10";
    String GO_RIGHT_REAR = "11";
    String GO_LEFT = "12";
    String GO_RIGHT = "13";

    int SPEED_OPT = 2;
    String SET_SPEED = "0";
    String MAX_SPEED = "100";

    /***摄像头操作*/
    int CAM_GENERAL_OP = 3;

    int CAM_SETTING_OP = 4;

    String START_SEND = "0";

    String STOP_SEND = "1";

    String LED_ON = "2";

    String LED_OFF = "3";

    /**
     * 速度控制
     */
    SpeedHandler SPEED_HANDLER = new SpeedHandler(new SimpleSpeedController(SPEED_OPT, SET_SPEED, MAX_SPEED), new SimpleController(CAR_GENERAL_OP, GO_PIKACHU));

    /**
     * 前
     */
    View.OnClickListener GO_FORWARD = new SimpleController(CAR_GENERAL_OP, FORWARD)::accept;

    /**
     * 倒车
     */
    View.OnClickListener GO_BACKWARD = new SimpleController(CAR_GENERAL_OP, BACKWARD)::accept;

    /**
     * 左转
     */
    View.OnTouchListener TO_TURN_LEFT = new TurnEventHandler(new SimpleController(CAR_GENERAL_OP, TURN_LEFT),
            new SimpleController(CAR_GENERAL_OP, END_TURN_LEFT));
    /**
     * 右转
     */
    View.OnTouchListener TO_TURN_RIGHT = new TurnEventHandler(new SimpleController(CAR_GENERAL_OP, TURN_RIGHT),
            new SimpleController(CAR_GENERAL_OP, END_TURN_RIGHT));

    /**
     * 按下左前松手停
     */
    View.OnTouchListener TO_GO_FRONT_LEFT = new TurnEventHandler(new SimpleController(CAR_GENERAL_OP, GO_FRONT_LEFT)
            , new SimpleController(CAR_GENERAL_OP, STOP));

    /**
     * 按下左后松手停
     */
    View.OnTouchListener TO_GO_REAR_LEFT = new TurnEventHandler(new SimpleController(CAR_GENERAL_OP, GO_REAR_LEFT)
            , new SimpleController(CAR_GENERAL_OP, STOP));

    /**
     * 按下右前松手停
     */
    View.OnTouchListener TO_GO_RIGHT_FRONT = new TurnEventHandler(new SimpleController(CAR_GENERAL_OP, GO_RIGHT_FRONT)
            , new SimpleController(CAR_GENERAL_OP, STOP));


    /**
     * 按下右后松手停
     */
    View.OnTouchListener TO_GO_RIGHT_REAR = new TurnEventHandler(new SimpleController(CAR_GENERAL_OP, GO_RIGHT_REAR)
            , new SimpleController(CAR_GENERAL_OP, STOP));

    /**
     * 按左移后松手停
     */
    View.OnTouchListener TO_GO_LEFT = new TurnEventHandler(new SimpleController(CAR_GENERAL_OP, GO_LEFT)
            , new SimpleController(CAR_GENERAL_OP, STOP));

    /**
     * 按左移后松手停
     */
    View.OnTouchListener TO_GO_RIGHT = new TurnEventHandler(new SimpleController(CAR_GENERAL_OP, GO_RIGHT)
            , new SimpleController(CAR_GENERAL_OP, STOP));

    /**
     * 停车
     */
    View.OnClickListener TO_STOP = new SimpleController(CAR_GENERAL_OP, STOP)::accept;


    SimpleController VIDEO_ON = new SimpleController(CAM_GENERAL_OP, START_SEND);

    SimpleController VIDEO_0FF = new SimpleController(CAM_GENERAL_OP, STOP_SEND);

    SimpleController LIGHT_ON = new SimpleController(CAM_GENERAL_OP, LED_ON);

    SimpleController LIGHT_OFF = new SimpleController(CAM_GENERAL_OP, LED_OFF);

    CompoundButton.OnCheckedChangeListener VIDEO_SWITCH = (buttonView, isChecked) -> {
        if (isChecked) {
            VIDEO_ON.accept(buttonView);
        } else {
            VIDEO_0FF.accept(buttonView);
        }
    };

    CompoundButton.OnCheckedChangeListener LIGHT_SWITCH = (buttonView, isChecked) -> {
        if (isChecked) {
            LIGHT_ON.accept(buttonView);
        } else {
            LIGHT_OFF.accept(buttonView);
        }
    };


}
